package com.example.service.impl;

import com.example.mapper.jobDescriptionMapp;
import com.example.pojo.jobDescriptionPojo;
import com.example.pojo.standardWorkListPojo;
import com.example.pojo.taskListDataPojo;
import com.example.service.jobDescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName:jobDescriptionImpl
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/9/11 23:35
 * @Version 1.0
 */
@Service
public class jobDescriptionImpl implements jobDescriptionService {
    @Autowired
    private jobDescriptionMapp jobDescriptionMapp;
    //插入一行数据
    public void insertOne(jobDescriptionPojo jobDescriptionPojo){
    //组合时间
    jobDescriptionPojo.setEstablishTime(LocalDateTime.now());
    jobDescriptionPojo.setUpdateTime(LocalDateTime.now());
    jobDescriptionMapp.insertOne(jobDescriptionPojo);
}
    //三个字段查询，都是字符串字段
    public List<jobDescriptionPojo> queryAllByThree(jobDescriptionPojo jobDescriptionPojo){
        String fieldOne="positionChinese";
        String fieldOneVal=jobDescriptionPojo.getPositionChinese();
        String fieldTwo="sectionName";
        String fieldTwoVal=jobDescriptionPojo.getSectionName();
        String fieldThree="departmentName";
        String fieldThreeVal=jobDescriptionPojo.getDepartmentName();
        List<jobDescriptionPojo> jobDescriptionPojoList=jobDescriptionMapp.queryAllByThreeStr(fieldOne,fieldOneVal,fieldTwo,fieldTwoVal,fieldThree,fieldThreeVal);
        return jobDescriptionPojoList;
    }
    //根据id，修改数据
    public void eidtOne(jobDescriptionPojo jobDescriptionPojo){
        //组合修改数据
        jobDescriptionPojo.setUpdateTime(LocalDateTime.now());
        jobDescriptionMapp.editOne(jobDescriptionPojo);
    }
    //根据id，删除数据
    public void deleteOnebyId(jobDescriptionPojo jobDescriptionPojo){
//        组合时间
        jobDescriptionPojo.setUpdateTime(LocalDateTime.now());
        jobDescriptionMapp.deleteOnebyId(jobDescriptionPojo);
    }
    //对标准工作，插入一行数据
    public void insertStandardWorkList(standardWorkListPojo standardWorkListPojo){
        standardWorkListPojo.setEstablishTime(LocalDateTime.now());
        standardWorkListPojo.setUpdateTime(LocalDateTime.now());
        jobDescriptionMapp.insertStandardWorkList(standardWorkListPojo);
    }
    //辅助函数，对标准工作中，查询出所有数据
    public List<standardWorkListPojo> inquiryStandardWorkListAll(){
        List<standardWorkListPojo> pojos=jobDescriptionMapp.inquiryStandardWorkListAll();
        return pojos;
    }
    //辅助函数，对标准工作中，根据ID，修改一行数据,修改所有数据
    public void upDataStandardWorkList(standardWorkListPojo pojo){
        pojo.setUpdateTime(LocalDateTime.now());
        jobDescriptionMapp.upDataStandardWorkList(pojo);
    }
    //辅助函数，对课题中插入一行
    public void insertTaskList(taskListDataPojo pojo){
        pojo.setEstablishTime(LocalDateTime.now());
        pojo.setUpdateTime(LocalDateTime.now());
        jobDescriptionMapp.insertTaskList(pojo);
    }
    //辅助函数，对课题中筛选出所有的数据
    public List<taskListDataPojo> inquiryTaskListAll(){
        List<taskListDataPojo> pojos=jobDescriptionMapp.inquiryTaskListAll();
        return pojos;
    }
    //辅助函数，对课题中插入一行,修改所有的内容
    public void upDataTaskList(taskListDataPojo pojo){
        pojo.setUpdateTime(LocalDateTime.now());
        jobDescriptionMapp.upDataTaskList(pojo);
    }

}
